<template>
<div class="row justify-content-center">
    <div class="col-md-12">
         <div class="row mb-3">
             <strong class="col-md-4" style="text-align:right">房源名称：</strong>
             <a :href="hid"><strong class="col-md-8" style="text-align:left">{{htitle}}</strong></a>
         </div>
         <div class="row mb-3">
             <strong class="col-md-4" style="text-align:right">
                 用户名称：
             </strong>
             <a :href="uid"><strong class="col-md-8" style="text-align:left">{{huname}}</strong></a>
         </div>
         <div class="row mb-3">
             <p class="col-md-4" style="text-align:right">
                 租赁时间：
             </p>
             <a href="#" class="col-md-8"><p style="text-align:left">{{hbegintime}} - {{hendtime}}</p></a>
         </div>
         <!--<div class="row mb-3 justify-content-center">
             <badge v-if="waitAudit" type="warning">待审核</badge>
             <badge v-if="Audit" type="success">审核通过</badge>
             <badge v-if="!Audit" type="danger">审核失败</badge>
             <badge v-if="close && isAudit" type="danger">交易关闭</badge>
         </div>-->
         <div class="row justify-content-center">
             <base-button  @click="updateStatus('pass')" v-if="!isAudit" type="success">通过</base-button>
             <base-button  @click="updateStatus('refuse')" v-if="!isAudit" type="danger">拒绝</base-button>
             <!--<base-button v-if="isAudit" type="danger">关闭交易</base-button>-->
         </div>
         <hr>
     </div>
     
</div>

</template>
<script>
    import {getHomeInfo} from "../../api";
    import {getUserInfo} from "../../api";
    import {updateApplicationStatus} from "../../api";
    export default {
        props: {
            // msg: {}
            msg:{
                begintime: String,
                endTime: String,
                status: String,
            }
        },
        data () {
            return {
                apply:false,
                pass:false,
                refuse:false,
                success:false,
                renewal:false,
                paid:false,
                title:'',
                uname:'',
                uid:'',
                hid:'',
                isAudit:false,
                Audit:true,
                waitAudit:true,
                close:true,
            }
        },
        computed:{
            hbegintime(){
                return this.msg.beginTime.substr(0,10).replace(/-/g,"/");
            },
            hendtime(){
                return this.msg.endTime.substr(0,10).replace(/-/g,"/");
            },
            htitle(){
                return this.title;
            },
            huname(){
                 return this.uname;   
            }
        },
        created() {
            getHomeInfo(this.msg.hid).then(res=>{
                if(this.msg.status=='apply'){
                    this.apply=true;
                }
                if(this.msg.status=='refuse'){
                    this.refuse=true;
                }
                if(this.msg.status=='pass'){
                    this.pass=true;
                }
                if(this.msg.status=='success'){
                    this.success=true;
                    this.paid=true;
                }
                if(this.msg.status=='renewal'){
                    this.renewal=true;
                    this.paid=true;
                }
                this.title=res.data.title;
                this.hid = "#/house/"+this.msg.hid;
            });
            getUserInfo(this.msg.uid).then(res=>{
                this.uid = "#/profile/" + this.msg.uid;
                this.uname = res.data.name;
            });
             
        },
        methods: {
             updateStatus(status){
                let formData = new FormData();
                formData.append('aid', this.msg.id);
                formData.append('tos', status);
                updateApplicationStatus(formData).then(res=>{
                    if(res.code == 1){
                        console.log("123");
                    }
                    this.$router.go(0);
                });
            }
        }
    };
</script>
<style>
.contentDiv{
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
    margin: auto;
}
</style>